var projectName = "租房管理系统";
/**
 * 轮播图配置
 */
var swiper = {
  // 设定轮播容器宽度，支持像素和百分比
  width: "100%",
  height: "400px",
  // hover（悬停显示）
  // always（始终显示）
  // none（始终不显示）
  arrow: "none",
  // default（左右切换）
  // updown（上下切换）
  // fade（渐隐渐显切换）
  anim: "default",
  // 自动切换的时间间隔
  // 默认3000
  interval: 2000,
  // 指示器位置
  // inside（容器内部）
  // outside（容器外部）
  // none（不显示）
  indicator: "outside",
};

/**
 * 个人中心菜单
 */
var centerMenu = [
  {
    name: "个人中心",
    url: "../" + localStorage.getItem("userTable") + "/center.html",
  },
  {
    name: "我的收藏",
    url: "../storeup/center.html",
  },
];

var indexNav = [
  {
    name: "房源信息",
    url: "./pages/fangyuanxinxi/list.html",
  },
  {
    name: "通知公告",
    url: "./pages/tongzhigonggao/list.html",
  },

  {
    name: "房屋资讯",
    url: "./pages/news/list.html",
  },
  {
    name: "留言反馈",
    url: "./pages/messages/list.html",
  },
];

var adminurl = "http://localhost:8080/springboot94sk3/admin/dist/index.html";

var cartFlag = false;

var chatFlag = false;

var menu = [
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "租客",
            menuJump: "列表",
            tableName: "zuke",
          },
        ],
        menu: "租客管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "屋主",
            menuJump: "列表",
            tableName: "wuzhu",
          },
        ],
        menu: "屋主管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除", "审核", "查看评论"],
            menu: "房源信息",
            menuJump: "列表",
            tableName: "fangyuanxinxi",
          },
        ],
        menu: "房源信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除", "审核"],
            menu: "订单信息",
            menuJump: "列表",
            tableName: "dingdanxinxi",
          },
        ],
        menu: "订单信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除"],
            menu: "租客评价",
            menuJump: "列表",
            tableName: "zukepingjia",
          },
        ],
        menu: "租客评价管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除"],
            menu: "屋主回复",
            menuJump: "列表",
            tableName: "wuzhuhuifu",
          },
        ],
        menu: "屋主回复管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除", "审核"],
            menu: "屋主申诉",
            menuJump: "列表",
            tableName: "wuzhushensu",
          },
        ],
        menu: "屋主申诉管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "通知公告",
            menuJump: "列表",
            tableName: "tongzhigonggao",
          },
        ],
        menu: "通知公告管理",
      },
      {
        child: [
          {
            buttons: ["查看", "回复", "删除"],
            menu: "留言板管理",
            tableName: "messages",
          },
        ],
        menu: "留言板管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "轮播图管理",
            tableName: "config",
          },
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "房屋资讯",
            tableName: "news",
          },
        ],
        menu: "系统管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看", "预约", "查看评论"],
            menu: "房源信息列表",
            menuJump: "列表",
            tableName: "fangyuanxinxi",
          },
        ],
        menu: "房源信息模块",
      },
      {
        child: [
          {
            buttons: ["查看"],
            menu: "通知公告列表",
            menuJump: "列表",
            tableName: "tongzhigonggao",
          },
        ],
        menu: "通知公告模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "否",
    hasFrontRegister: "否",
    roleName: "管理员",
    tableName: "users",
  },
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["查看"],
            menu: "预约看房",
            menuJump: "列表",
            tableName: "yuyuekanfang",
          },
        ],
        menu: "预约看房管理",
      },
      {
        child: [
          {
            buttons: ["查看", "发布评价", "支付"],
            menu: "订单信息",
            menuJump: "列表",
            tableName: "dingdanxinxi",
          },
        ],
        menu: "订单信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除"],
            menu: "租客评价",
            menuJump: "列表",
            tableName: "zukepingjia",
          },
        ],
        menu: "租客评价管理",
      },
      {
        child: [
          {
            buttons: ["查看"],
            menu: "屋主回复",
            menuJump: "列表",
            tableName: "wuzhuhuifu",
          },
        ],
        menu: "屋主回复管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看", "预约", "查看评论"],
            menu: "房源信息列表",
            menuJump: "列表",
            tableName: "fangyuanxinxi",
          },
        ],
        menu: "房源信息模块",
      },
      {
        child: [
          {
            buttons: ["查看"],
            menu: "通知公告列表",
            menuJump: "列表",
            tableName: "tongzhigonggao",
          },
        ],
        menu: "通知公告模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "是",
    hasFrontRegister: "是",
    roleName: "租客",
    tableName: "zuke",
  },
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除", "查看评论"],
            menu: "房源信息",
            menuJump: "列表",
            tableName: "fangyuanxinxi",
          },
        ],
        menu: "房源信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "审核"],
            menu: "预约看房",
            menuJump: "列表",
            tableName: "yuyuekanfang",
          },
        ],
        menu: "预约看房管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "订单信息",
            menuJump: "列表",
            tableName: "dingdanxinxi",
          },
        ],
        menu: "订单信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "回复", "申诉"],
            menu: "租客评价",
            menuJump: "列表",
            tableName: "zukepingjia",
          },
        ],
        menu: "租客评价管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除", "修改"],
            menu: "屋主回复",
            menuJump: "列表",
            tableName: "wuzhuhuifu",
          },
        ],
        menu: "屋主回复管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除"],
            menu: "屋主申诉",
            menuJump: "列表",
            tableName: "wuzhushensu",
          },
        ],
        menu: "屋主申诉管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看", "预约", "查看评论"],
            menu: "房源信息列表",
            menuJump: "列表",
            tableName: "fangyuanxinxi",
          },
        ],
        menu: "房源信息模块",
      },
      {
        child: [
          {
            buttons: ["查看"],
            menu: "通知公告列表",
            menuJump: "列表",
            tableName: "tongzhigonggao",
          },
        ],
        menu: "通知公告模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "是",
    hasFrontRegister: "是",
    roleName: "屋主",
    tableName: "wuzhu",
  },
];

var isAuth = function (tableName, key) {
  let role = localStorage.getItem("userTable");
  let menus = menu;
  for (let i = 0; i < menus.length; i++) {
    if (menus[i].tableName == role) {
      for (let j = 0; j < menus[i].backMenu.length; j++) {
        for (let k = 0; k < menus[i].backMenu[j].child.length; k++) {
          if (tableName == menus[i].backMenu[j].child[k].tableName) {
            let buttons = menus[i].backMenu[j].child[k].buttons.join(",");
            return buttons.indexOf(key) !== -1 || false;
          }
        }
      }
    }
  }
  return false;
};

var isFrontAuth = function (tableName, key) {
  let role = localStorage.getItem("userTable");
  let menus = menu;
  for (let i = 0; i < menus.length; i++) {
    if (menus[i].tableName == role) {
      for (let j = 0; j < menus[i].frontMenu.length; j++) {
        for (let k = 0; k < menus[i].frontMenu[j].child.length; k++) {
          if (tableName == menus[i].frontMenu[j].child[k].tableName) {
            let buttons = menus[i].frontMenu[j].child[k].buttons.join(",");
            return buttons.indexOf(key) !== -1 || false;
          }
        }
      }
    }
  }
  return false;
};
